package com.oocl.homework.character;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CharacterCounter {
	
//	private Pattern alphabetPattern;
//	private Pattern digitPattern;
//	private Pattern chineseCharacterPattern;
//	private Pattern punctuationCountPattern;
	
	
	
	public int alphabetCounter(String s){
		 return count("[a-zA-Z]+", s);
	}
	
	public int digitCounter(String s){
		 return count("[0-9]+", s);
	}
	
	
	public int chineseCharacter(String s){
		return count("[\\u4e00-\\u9fa5]+", s);
	}
	
	public int punctuationCharacter(String s){
		return count("[\\pP]+", s);
	}
	
	
	private int count(String pattern,String s){
		 Pattern alphabetPattern = Pattern.compile(pattern);
		 Matcher matcher = alphabetPattern.matcher(s);
		 StringBuilder stringBuilder = new StringBuilder();
		 while (matcher.find()) {
			stringBuilder.append(matcher.group());
		}
		 return stringBuilder.length();
	}
	
//	
//	public Result find(String s){
//		Result result = new Result();
//		result.setAlphabetCount(alphabetCount);
//		result.setDigitCount(digitCount);
//		result.setChineseCharacterCount(chineseCharacterCount);
//		result.setPunctuationCount(punctuationCount);
//		return
//	}

}
